package com.briup.mt.service.impl;

import com.briup.mt.bean.*;
import com.briup.mt.dao.ApplicationMapper;
import com.briup.mt.dao.BaseConfigMapper;
import com.briup.mt.service.IBaseConfigService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 姜鑫
 * @version 1.0
 * @date 2020/12/16 11:10
 */
@Service
public class BaseConfigServiceImpl implements IBaseConfigService {
@Resource
    private BaseConfigMapper baseconfigMapper;

    @Override
    public List<BaseConfig> query(String name) {
        BaseConfigExample example =new BaseConfigExample();
        if (!StringUtils.isEmpty(name)){
            example.createCriteria().andNameLike("%"+name+"%");
        }
        return baseconfigMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(BaseConfig baseConfig) {
        if (baseConfig.getId() == null) {
            baseconfigMapper.insert(baseConfig);
        }else{
            baseconfigMapper.updateByPrimaryKey(baseConfig);
        }
    }

    @Override
    public void deleteById(long id) {

        baseconfigMapper.deleteByPrimaryKey(id);
    }
}
